#ifndef _RTXAPIREDEFINE_H
#define _RTXAPIREDEFINE_H
#include <RTL.H>



/* Return codes */
#define osRxTimerOut			OS_R_TMO       
#define osRxFlag				OS_R_EVT       
#define osRxSem					OS_R_SEM       
#define osRxMbox				OS_R_MBX        
#define osRxMutex				OS_R_MUT        
#define osRxOK					OS_R_OK        
#define osRxErr					OS_R_NOK  

#define osOK					OS_R_OK   
/* Error Codes */
#define osErrStkOverFlow		OS_ERR_STK_OVF  
#define osErrFifoOverFlow		OS_ERR_FIFO_OVF 
#define osErrMboxOverFlow		OS_ERR_MBX_OVF  

#define WAIT_FOR_EVER										0xFFFF


#define osTickGet()											os_time_get()              
#define osDlyTick(delay_time)								os_dly_wait(delay_time)    
#define osIntervalSet(interval_time)  						os_itv_set(interval_time)  
#define osIntervalWait()									os_itv_wait()              

#define osSchedulerLock()									tsk_lock()                 
#define osSchedulerUnlock()									tsk_unlock()             
#define osSchedulerSuspend()								os_suspend()               
#define osSchedulerResume(sleep_time)						os_resume(sleep_time)      
 
#define osSatrt(taskName) 									os_sys_init(taskName)  
#define osSatrtPriority(taskName,prio)						os_sys_init_prio(taskName,prio)              
#define osStartUser(taskName,prio,stk,size)					os_sys_init_user(taskName,prio,stk,size)                                   
                                     
#define osTaskCreate(taskName,prio)							os_tsk_create(taskName,prio)
#define osTaskCreateEx(taskName,prio,argv) 					os_tsk_create_ex(taskName,prio,argv) 
#define osTaskCreateUser(taskName,prio,stk,size)			os_tsk_create_user(taskName,prio,stk,size)                                                                  
#define osTaskCreateUserEx(taskName,prio,stk,size,argv) 	os_tsk_create_user_ex(taskName,prio,stk,size,argv)                   
#define osTaskDelete(task_id) 								os_tsk_delete(task_id)        
#define osTaskDeleteSelf()									os_tsk_delete_self()        
#define osTaskIsrGetID()									isr_tsk_get()                 
#define osTaskGetSelfID()									os_tsk_self()                 
#define osTaskNewPriority(task_id,new_prio)					os_tsk_prio(task_id,new_prio) 
#define osTaskNewPrioritySelf(prio)							os_tsk_prio_self(prio)       
#define osTaskPass()										os_tsk_pass()

#define osEventIsrSet(flags,task_id)						isr_evt_set (flags,task_id)
#define osEventSet(flags,task_id)							os_evt_set(flags,task_id)
#define osEventGet()										os_evt_get()
#define osEventWaitOr(flags,tmo) 							os_evt_wait_or(flags,tmo)    
#define osEventWaitAnd(flags,tmo) 							os_evt_wait_and(flags,tmo)   
#define osEventClear(flags,task_id)							os_evt_clr(flags,task_id)

#define osSignalsIsrSet(flags,task_id)						isr_evt_set (flags,task_id)
#define osSignalsSet(flags,task_id)							os_evt_set(flags,task_id)
#define osSignalsGet()										os_evt_get()
#define osSignalsWaitOr(flags,tmo) 							os_evt_wait_or(flags,tmo)    
#define osSignalsWaitAnd(flags,tmo) 						os_evt_wait_and(flags,tmo)   
#define osSignalsClear(flags,task_id)						os_evt_clr(flags,task_id)


#define osMutexCreate(mutexName) 							os_mut_init(mutexName)         
#define osMutexWait(mutexName,timeout)						os_mut_wait(mutexName,timeout)
#define osMutexRelease(mutexName)							os_mut_release(mutexName)     

#define osSemCreate(semName,semVal)							os_sem_init(semName,semVal)     
#define osSemRelease(semName)   							os_sem_send(semName) 
#define	osSemIncIsr(semName)								isr_sem_send (semName)
#define osSemWait(semName,tmo)								os_sem_wait(semName,tmo)        


#define osMessageBoxDeclare(mboxName,cnt)					os_mbx_declare(mboxName,cnt)
#define osMessageBoxCreate(mboxName,mbx_size)				os_mbx_init(mboxName,mbx_size)     
#define osMessageBoxSend(mboxName,p_msg,tmo)				os_mbx_send(mboxName,p_msg,tmo)    
#define osMessageBoxWait(mboxName,p_msg,tmo)				os_mbx_wait(mboxName,p_msg,tmo)  
#define osMessageBoxCheck(mboxName)							os_mbx_check(mboxName)             
#define osMessageBoxCheckIsr(mboxName)						isr_mbx_check(mboxName)            
#define osMessageBoxSendIsr(mboxName,p_msg)					isr_mbx_send (mboxName,p_msg)
#define osMessageBoxReceiveIsr(mboxName,p_msg)				isr_mbx_receive (mboxName,p_msg)

#define osMemPoolDeclare(PoolName,ByteSize,Blocks)			_declare_box(PoolName,ByteSize,Blocks)  
#define osMemPoolCreate(PoolName,PoolSize,BlkSize)		  	_init_box (PoolName,PoolSize,BlkSize)
#define osMemPool8Declare(PoolName,ByteSize,Blocks) 		_declare_box8(PoolName,ByteSize,Blocks) 
#define osMemPool8Create(PoolName,PoolSize,BlkSize) 		osC_init_box8(PoolName,PoolSize,BlkSize) 
#define osMemPoolGet(PoolName)								_alloc_box (PoolName)
#define osMemPoolGetClear(PoolName)							*_calloc_box (PoolName)
#define osMemPoolPut(PoolName,box)							_free_box (PoolName,box)

#define osMemoryDeclare(PoolName,ByteSize,Blocks)			_declare_box(PoolName,ByteSize,Blocks)  
#define osMemoryCreate(PoolName,PoolSize,BlkSize)		  	_init_box (PoolName,PoolSize,BlkSize)
#define osMemory8Declare(PoolName,ByteSize,Blocks) 			_declare_box8(PoolName,ByteSize,Blocks) 
#define osMemory8Create(PoolName,PoolSize,BlkSize) 			osC_init_box8(PoolName,PoolSize,BlkSize) 
#define osMemoryGet(PoolName)								_alloc_box (PoolName)
#define osMemoryGetClear(PoolName)							*_calloc_box (PoolName)
#define osMemoryPut(PoolName,box)							_free_box (PoolName,box)


#define osTimerCreate(Tick,Callback_data)					os_tmr_create(Tick,Callback_data)
#define osTimerDelete(timerID)								os_tmr_kill (timerID)



#endif
